1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.UnixCredentialsMessage;
26 
27 private import gio.Credentials;
28 private import gio.SocketControlMessage;
29 private import gio.c.functions;
30 public  import gio.c.types;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 
34 
35 /**
36  * This #GSocketControlMessage contains a #GCredentials instance.  It
37  * may be sent using g_socket_send_message() and received using
38  * g_socket_receive_message() over UNIX sockets (ie: sockets in the
39  * %G_SOCKET_FAMILY_UNIX family).
40  * 
41  * For an easier way to send and receive credentials over
42  * stream-oriented UNIX sockets, see
43  * g_unix_connection_send_credentials() and
44  * g_unix_connection_receive_credentials(). To receive credentials of
45  * a foreign process connected to a socket, use
46  * g_socket_get_credentials().
47  * 
48  * Since GLib 2.72, #GUnixCredentialMessage is available on all platforms. It
49  * requires underlying system support (such as Windows 10 with `AF_UNIX`) at run
50  * time.
51  * 
52  * Before GLib 2.72, `<gio/gunixcredentialsmessage.h>` belonged to the UNIX-specific
53  * GIO interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file
54  * when using it. This is no longer necessary since GLib 2.72.
55  *
56  * Since: 2.26
57  */
58 public class UnixCredentialsMessage : SocketControlMessage
59 {
60 	/** the main Gtk struct */
61 	protected GUnixCredentialsMessage* gUnixCredentialsMessage;
62 
63 	/** Get the main Gtk struct */
64 	public GUnixCredentialsMessage* getUnixCredentialsMessageStruct(bool transferOwnership = false)
65 	{
66 		if (transferOwnership)
67 			ownedRef = false;
68 		return gUnixCredentialsMessage;
69 	}
70 
71 	/** the main Gtk struct as a void* */
72 	protected override void* getStruct()
73 	{
74 		return cast(void*)gUnixCredentialsMessage;
75 	}
76 
77 	/**
78 	 * Sets our main struct and passes it to the parent class.
79 	 */
80 	public this (GUnixCredentialsMessage* gUnixCredentialsMessage, bool ownedRef = false)
81 	{
82 		this.gUnixCredentialsMessage = gUnixCredentialsMessage;
83 		super(cast(GSocketControlMessage*)gUnixCredentialsMessage, ownedRef);
84 	}
85 
86 
87 	/** */
88 	public static GType getType()
89 	{
90 		return g_unix_credentials_message_get_type();
91 	}
92 
93 	/**
94 	 * Creates a new #GUnixCredentialsMessage with credentials matching the current processes.
95 	 *
96 	 * Returns: a new #GUnixCredentialsMessage
97 	 *
98 	 * Since: 2.26
99 	 *
100 	 * Throws: ConstructionException GTK+ fails to create the object.
101 	 */
102 	public this()
103 	{
104 		auto __p = g_unix_credentials_message_new();
105 
106 		if(__p is null)
107 		{
108 			throw new ConstructionException("null returned by new");
109 		}
110 
111 		this(cast(GUnixCredentialsMessage*) __p, true);
112 	}
113 
114 	/**
115 	 * Creates a new #GUnixCredentialsMessage holding @credentials.
116 	 *
117 	 * Params:
118 	 *     credentials = A #GCredentials object.
119 	 *
120 	 * Returns: a new #GUnixCredentialsMessage
121 	 *
122 	 * Since: 2.26
123 	 *
124 	 * Throws: ConstructionException GTK+ fails to create the object.
125 	 */
126 	public this(Credentials credentials)
127 	{
128 		auto __p = g_unix_credentials_message_new_with_credentials((credentials is null) ? null : credentials.getCredentialsStruct());
129 
130 		if(__p is null)
131 		{
132 			throw new ConstructionException("null returned by new_with_credentials");
133 		}
134 
135 		this(cast(GUnixCredentialsMessage*) __p, true);
136 	}
137 
138 	/**
139 	 * Checks if passing #GCredentials on a #GSocket is supported on this platform.
140 	 *
141 	 * Returns: %TRUE if supported, %FALSE otherwise
142 	 *
143 	 * Since: 2.26
144 	 */
145 	public static bool isSupported()
146 	{
147 		return g_unix_credentials_message_is_supported() != 0;
148 	}
149 
150 	/**
151 	 * Gets the credentials stored in @message.
152 	 *
153 	 * Returns: A #GCredentials instance. Do not free, it is owned by @message.
154 	 *
155 	 * Since: 2.26
156 	 */
157 	public Credentials getCredentials()
158 	{
159 		auto __p = g_unix_credentials_message_get_credentials(gUnixCredentialsMessage);
160 
161 		if(__p is null)
162 		{
163 			return null;
164 		}
165 
166 		return ObjectG.getDObject!(Credentials)(cast(GCredentials*) __p);
167 	}
168 }